package com.wrupple.muba.common.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.google.gwt.user.client.rpc.IsSerializable;

public class FilterCriteria implements Serializable, IsSerializable {
	private static final long serialVersionUID = -369384271702851519L;
	private List<String> values;
	private String operator;
	private String[] path;

	public FilterCriteria() {
		super();
		values= new ArrayList<String>();
	}

	public String getOperator() {
		return operator;
	}

	public void setOperator(String operator) {
		this.operator = operator;
	}

	public List<String> getValues() {
		return values;
	}

	public void setValues(List<String> values) {
		this.values = values;
	}

	@Override
	public String toString() {
		return "FilterCriteria [value=" + values + ", operator=" + operator + ", path=" + Arrays.toString(path) + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((operator == null) ? 0 : operator.hashCode());
		result = prime * result + ((values == null) ? 0 : values.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FilterCriteria other = (FilterCriteria) obj;
		if (operator == null) {
			if (other.operator != null)
				return false;
		} else if (!operator.equals(other.operator))
			return false;
		if (values == null) {
			if (other.values != null)
				return false;
		} else if (!values.equals(other.values))
			return false;
		return true;
	}

	public void setPath(String[] path) {
		this.path = path;
	}

	public String[] getPath() {
		return path;
	}

	public void setValue(String value) {
		values.add(value);
	}

	public String getValue() {
		return values.size()>0? values.get(0) : null;
	}


	
	

}